package com.mz.mattress.admin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mz.mattress.api.entity.OrderUseTimes;
import com.mz.mattress.api.entity.SummaryTimes;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface OrderUseTimesMapper extends BaseMapper<OrderUseTimes> {

    IPage<OrderUseTimes> listPage(Page page,
                                  @Param("orderId") String orderId,
                                  @Param("merchantId") Integer merchantId,
                                  @Param("merchantName") String merchantName,
                                  @Param("deviceId") Integer deviceId,
                                  @Param("startTime") String startTime,
                                  @Param("endTime") String endTime,
                                  @Param("city") String city);

    SummaryTimes listTotal(@Param("orderId") String orderId,
                           @Param("merchantId") Integer merchantId,
                           @Param("merchantName") String merchantName,
                           @Param("deviceId") Integer deviceId,
                           @Param("startTime") String startTime,
                           @Param("endTime") String endTime);

    @Select("select * from mz_order_use_times where order_id=#{orderId} and deleted=0 order by id desc")
    List<OrderUseTimes> list(@Param("orderId") Long orderId);

    @Select("select * from mz_order_use_times where status=#{status} and deleted=0 order by id desc")
    List<OrderUseTimes> listByStatus(@Param("status") Integer status);

    //这商家 已消费的 客户手机号
    @Select("select distinct mobile from mz_order_use_times where merchant_id=#{merchantId} and status>1 and deleted=0")
    IPage<String> selectMobileByMerchantId(Page page, @Param("merchantId") Integer merchantId);

}
